package edu.wtbu.cs.androiddemo.extra;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;

import edu.wtbu.cs.androiddemo.R;
import edu.wtbu.cs.androiddemo.activity.list.MyAdapter;
import edu.wtbu.cs.androiddemo.activity.list.RecyclerViewSampleActivity;

public class VideoSnapSampleActivity extends AppCompatActivity {

    private PagerSnapHelper mPagerSnapHelper;
    private RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_video_snap_sample);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        recyclerView = findViewById(R.id.video_recyclerView);

        MyAdapter myAdapter = new MyAdapter(VideoSnapSampleActivity.this);
        recyclerView.setAdapter(myAdapter);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(VideoSnapSampleActivity.this);
        //实现横向布局
//        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(RecyclerViewSampleActivity.this,
//                LinearLayoutManager.HORIZONTAL,false);

        recyclerView.setLayoutManager(linearLayoutManager);

        mPagerSnapHelper= new PagerSnapHelper();


        mPagerSnapHelper.attachToRecyclerView(recyclerView);


    }
}